package com.cc.spring.domain;

import com.alibaba.excel.annotation.ExcelProperty;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Objects;

public class User {
    private Long id;
    @ExcelProperty("用户名")
    private String userName;
    @ExcelProperty("密码")
    private String password;
    @ExcelProperty("昵称")
    private String nickName;
    @ExcelProperty("权限")
    private Integer permission;
    @ExcelProperty("是否可用")
    private Integer isAble;

    public User() {

    }

    public User(Long id, String userName, String password, String nickName, Integer permission, Integer isAble) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.nickName = nickName;
        this.permission = permission;
        this.isAble = isAble;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName == null ? null : nickName.trim();
    }

    public Integer getPermission() {
        return permission;
    }

    public void setPermission(Integer permission) {
        this.permission = permission;
    }

    public Integer getIsAble() {
        return isAble;
    }

    public void setIsAble(Integer isAble) {
        this.isAble = isAble;
    }

//    重写equals，使用用户名判断是不是同一个用户
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(userName, user.userName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userName);
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", nickName='" + nickName + '\'' +
                ", permission=" + permission +
                ", isAble=" + isAble +
                '}';
    }
}